﻿using Ping9719.WpfEx.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace AutoFlatnessTest.ViewModel
{
    public enum BoardMinState
    {
        准备,
        进行中,
        通过,
        未通过,
        空白
    }

    public class UcBoardMinVModel : BindableBase
    {

        private string txtTiT;

        public string TxtTiT
        {
            get { return txtTiT; }
            set { txtTiT = value; RaisePropertyChanged(nameof(TxtTiT)); }
        }

        private Brush backColor = Brushes.LightGray;

        public Brush BackColor
        {
            get { return backColor; }
            set { backColor = value; RaisePropertyChanged(nameof(BackColor)); }
        }

        private string txtMa;

        public string TxtMa
        {
            get { return txtMa; }
            set { txtMa = value; RaisePropertyChanged(nameof(TxtMa)); }
        }

        private string txtVal;

        public string TxtVal
        {
            get { return txtVal; }
            set { txtVal = value; RaisePropertyChanged(nameof(TxtVal)); }
        }

        private string txtValTip;

        public string TxtValTip
        {
            get { return txtValTip; }
            set { txtValTip = value; RaisePropertyChanged(nameof(TxtValTip)); }
        }

        private Visibility visLoad = Visibility.Collapsed;

        public Visibility VisLoad
        {
            get { return visLoad; }
            set { visLoad = value; RaisePropertyChanged(nameof(VisLoad)); }
        }

        public void SetState(BoardMinState state, string val = null, string ma = null)
        {
            if (state == BoardMinState.准备)
            {
                BackColor = Brushes.LightGray;
                TxtVal = string.Empty;
                TxtMa = string.Empty;
                VisLoad = Visibility.Collapsed;
            }
            else if (state == BoardMinState.进行中)
            {
                BackColor = Brushes.LightGray;
                if (val != null)
                    TxtVal = val;
                if (ma != null)
                    TxtMa = ma;
                VisLoad = Visibility.Visible;
            }
            else if (state == BoardMinState.通过)
            {
                BackColor = Brushes.MediumSeaGreen;
                if (val != null)
                    TxtVal = val;
                if (ma != null)
                    TxtMa = ma;
                VisLoad = Visibility.Collapsed;
            }
            else if (state == BoardMinState.未通过)
            {
                //BackColor = Brushes.IndianRed;
                BackColor = Brushes.Red;
                if (val != null)
                    TxtVal = val;
                if (ma != null)
                    TxtMa = ma;
                VisLoad = Visibility.Collapsed;
            }
            else if (state == BoardMinState.空白)
            {
                BackColor = Brushes.DimGray;
                if (val != null)
                    TxtVal = val;
                if (ma != null)
                    TxtMa = ma;
                VisLoad = Visibility.Collapsed;
            }
        }

        public void Stop()
        {
            VisLoad = Visibility.Collapsed;
        }

    }
}
